﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Forms;
using Microsoft.WindowsCE.Forms;
using SSM.SmartMosaicUtils.Net; 

namespace smart_test
{
    public partial class CaptureFrm : Form
    {
        private Form1 frm1;
        private string imageFileName;

        public CaptureFrm(Form1 form1)
        {
            InitializeComponent();
            this.Load += new EventHandler(CaptureFrm_Load);
            frm1 = form1;
        }

        void CaptureFrm_Load(object sender, EventArgs e)
        {
            SystemSettings.ScreenOrientation = ScreenOrientation.Angle0;
            CameraCaptureDialog ccd = new CameraCaptureDialog();
            ccd.Mode = CameraCaptureMode.Still;
            ccd.StillQuality = CameraCaptureStillQuality.High;
            ccd.Title = "Smart Mosaic";

            if (ccd.ShowDialog() == DialogResult.OK)
            {
                frm1.ChangeWaitPanel();

                imageFileName = ccd.FileName;

                captureImage.Image = new Bitmap(ccd.FileName);
                SystemSettings.ScreenOrientation = ScreenOrientation.Angle270;
            }
            else
            {
                frm1.CloseWaitPanel();
                SystemSettings.ScreenOrientation = ScreenOrientation.Angle270;
                this.Close();
            }


            
        }

        private void btCapture_Click(object sender, EventArgs e)
        {
            frm1.ChangeWaitPanel2();
            this.Visible = false;
            SystemSettings.ScreenOrientation = ScreenOrientation.Angle0;
            CameraCaptureDialog ccd = new CameraCaptureDialog();
            ccd.Mode = CameraCaptureMode.Still;
            ccd.StillQuality = CameraCaptureStillQuality.High;
            ccd.Title = "Smart Mosaic";

            if (ccd.ShowDialog() == DialogResult.OK)
            {
                frm1.ChangeWaitPanel();
                imageFileName = ccd.FileName;
                captureImage.Image = new Bitmap(ccd.FileName);
                SystemSettings.ScreenOrientation = ScreenOrientation.Angle270;
                this.Visible = true;
            }
        }

        private void btBack_Click(object sender, EventArgs e)
        {
            frm1.CloseWaitPanel();
            this.Close();
        }

        private void btUpload_Click(object sender, EventArgs e)
        {
            //new FileUploader().UploadFile(imageFileName);
            UploadFrm uf = new UploadFrm(imageFileName);
            uf.Show();
            frm1.CloseWaitPanel();
            this.Close();

        }
        private void btCapture_MouseUp(object sender, MouseEventArgs e)
        {
            btCapturePress.Visible = false;
        }

        private void btCapture_MouseDown(object sender, MouseEventArgs e)
        {
            btCapturePress.Visible = true;
        }

        private void btBack_MouseDown(object sender, MouseEventArgs e)
        {
            btBackPress.Visible = true;
        }

        private void btBack_MouseUp(object sender, MouseEventArgs e)
        {
            btBackPress.Visible = false;
        }

        private void btUpload_MouseUp(object sender, MouseEventArgs e)
        {
            btUploadPress.Visible = false;
        }

        private void btUpload_MouseDown(object sender, MouseEventArgs e)
        {
            btUploadPress.Visible = true;
        }
    }
}